package com.example.tg.Controller;


import api.purchase.purchaseApi;


import com.example.tg.Service.*;
import com.github.pagehelper.PageInfo;
import dto.Dto;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pojo.*;

import java.util.List;

@RestController
public class purchase_orderController implements purchaseApi {
    @Autowired
    private purchase_orderService purchase_orderService;
    @Autowired
    private PurchaselistService purchaselistService;
    @Autowired
    private PurchaseReturnService purchaseReturnService;
    @Autowired
    private SupplierService supplierService;




    @Override
    public Dto<Integer> addPo(Purchase purchase) {
        Dto<Integer> dto=new Dto<>();
        dto.setObj(purchase_orderService.addPo(purchase));
        return dto;
    }

    @Override
    public Dto<Integer> delePo(String  id) {
        Dto<Integer> dto=new Dto<>();
        dto.setObj(purchase_orderService.delePo(id));
        return dto;
    }

    @Override
    public Dto<Integer> updaPo(PurchaseOrder purchaseOrder) {
        Dto<Integer> dto=new Dto();
        dto.setObj(purchase_orderService.updaPo(purchaseOrder));
        return dto;
    }

    @Override
    public Dto<List<String>> showPid() {
        Dto<List<String>> dto = new Dto<>();
        dto.setObj(purchase_orderService.showPid());
        return dto;
    }



    @Override
    public Dto<Integer> updaPo2(Xgzt xgzt) {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(purchase_orderService.updaPo2(xgzt));
        return dto;
    }


    @Override
    public Dto<PageInfo<PurchaseOrder>> ListPo(ListPo listPo) {
        Dto<PageInfo<PurchaseOrder>> dto = new Dto<>();
        dto.setObj(purchase_orderService.ListPo(listPo));
        dto.setMsg("成功");
        dto.setCode(200);
        dto.setSuccess(true);
        return dto;
    }

    @Override
    public Dto<Integer> contPo() {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(purchase_orderService.contPo());
        return dto;
    }

    @Override
    public Dto<PurchaseOrder> show1Po(String pid) {
        Dto<PurchaseOrder> dto = new Dto<>();
        dto.setObj(purchase_orderService.show1Po(pid));
        return dto;
    }


    @Override
    public Dto<Integer> addPl(List<PurchaseList> list) {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(purchaselistService.addPl(list));
        return dto;
    }

    @Override
    public Dto<Integer> addPl2(List<PurchaseList> list) {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(purchaselistService.addPl2(list));
        return dto;
    }

    @Override
    public Dto<List> listPl(String pid) {
        Dto<List> dto = new Dto<>();
        dto.setObj(purchaselistService.listPl(pid));
        return dto;
    }

    @Override
    public Dto<Integer> delePl(String id) {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(purchaselistService.delePl(id));
        return dto;
    }

    @Override
    public Dto<Integer> updaPl(List<Xgth> list) {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(purchaselistService.updaPl(list));
        return dto;
    }


    /**
     * 采购退货
     * @return
     */
    @Override
    public Dto<Integer> addPr(Pr pr) {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(purchaseReturnService.addPr(pr));
        return dto;
    }

    @Override
    public Dto<Integer> delePr(String id) {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(purchaseReturnService.delePr(id));
        return dto;
    }



    @Override
    public Dto<PageInfo<PurchaseReturn>> listPr(ListPo listPo) {
        Dto<PageInfo<PurchaseReturn>> dto =new Dto<>();
        dto.setObj((purchaseReturnService.listPr(listPo)));
        return dto;
    }

    @Override
    public Dto<Integer> contPr() {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(purchaseReturnService.contPr());
        return dto;
    }

    @Override
    public Dto<PurchaseReturn> showPr(String code) {
        Dto<PurchaseReturn> dto = new Dto<>();
        dto.setObj(purchaseReturnService.showPr(code));
        return dto;
    }



    @Override
    public Dto<Integer> updaPr(Xgzt xgzt) {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(purchaseReturnService.updaPr(xgzt));
        return dto;
    }


    /**
     * @param supplier
     * 供应商
     * @return
     */
    @Override
    public Dto<Integer> addSp(Supplier supplier) {
        Dto<Integer> dto=new Dto<>();
        dto.setObj(supplierService.addSp(supplier));
        return dto;
    }

    @Override
    public Dto<Integer> deleSp(int id) {
        Dto<Integer> dto= new Dto<>();
        dto.setObj(supplierService.deleSp(id));
        return dto;
    }

    @Override
    public Dto<Integer> updaSp(Supplier supplier) {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(supplierService.updaSp(supplier));
        return dto;
    }

    @Override
    public Dto<PageInfo<Supplier>> listSp(String name,int pageNum,int pageSize) {
        Dto<PageInfo<Supplier>> dto = new Dto<>();
        dto.setObj(supplierService.listSp(name,pageNum,pageSize));
        return dto;
    }


    @Override
    public Dto<Integer> contSp() {
        Dto<Integer> dto = new Dto<>();
        dto.setObj(supplierService.contSp());
        return dto;
    }

    @Override
    public Dto<List<String>> nameSp() {
        Dto<List<String>> dto = new Dto<>();
        dto.setObj(supplierService.nameSp());
        return dto;
    }

    @Override
    public Dto<Supplier> showSp(Integer id) {
        Dto<Supplier> dto = new Dto<>();
        dto.setObj(supplierService.showSp(id));
        return dto;
    }



    @Override
    public Dto<Supplier> showSp2(String name) {
        Dto<Supplier> dto = new Dto<>();
        dto.setObj(supplierService.showSp2(name));
        return dto;
    }
}
